const _ = require('lodash');
function add(a, b, c) {
  return a + b + c;
}

const curry = (fn) => {
  const fnLength = fn.length;
  const curried = (...args) => {
    if (args.length < fnLength) {
      return (...args2) => curried(...args, ...args2);
    }
    return fn(...args);
  };
  return curried;
};

// const curriedAdd = _.curry(add);
const curriedAdd = curry(add);
console.log(curriedAdd(1)(2)(3));
console.log(curriedAdd(1, 2, 3));
console.log(curriedAdd(1, 2)(3));
console.log(curriedAdd(1, 2)(3, 4, 5));
